<template>
    <h1>投资项目添加</h1>

    <table>
        <tr>
            <td>投资项目名称</td>
            <td>
                <input type="text" v-model="Invest.I_Name">
            </td>
        </tr>

        <tr>
            <td>投资项目总金额</td>
            <td>
                <input type="text" v-model="Invest.I_SumMoney">
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <input type="button" value="添加" @click="InvestAdd">
            </td>
        </tr>

    </table>


</template>

<script setup lang="ts">

import {ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router';

const router = useRouter();

const Invest = ref({
    I_Name:'',
    I_SumMoney:''
})

const InvestAdd = () => {
    axios({
        method:'post',
        url:'http://localhost:64202/api/Invest/InvestAdd',
        data:{
            I_Name:Invest.value.I_Name,
            I_SumMoney:Invest.value.I_SumMoney
        }
    })
    .then(res => {
        if(res.data>0){
            alert('添加成功');
            router.push('/InvestShow');
        }
        else{
            alert('添加失败');
        }
    })
    .catch(err => {
        console.log(err)
    })
}

</script>
